package com.barry.pattern.singleton;

/**
 * @ClassName SingletonLh
 * @Description TODO
 * @Author wangxuexing
 * @Date 2020/2/17 15:44
 * @Version 1.0
 */
public class SingletonLh {
    private static volatile SingletonLh singletonLh;

    private SingletonLh(){}

    public static SingletonLh getInstance(){
        if(singletonLh == null){
            synchronized (SingletonLh.class){
                if(singletonLh == null){
                    singletonLh = new SingletonLh();
                }
            }
        }
        return singletonLh;
    }

    public static void main(String[] args) {
        SingletonLh a = SingletonLh.getInstance();
        SingletonLh b = SingletonLh.getInstance();
        System.out.println((a==b));
    }
}
